package com.home.homepage.controller.prefecture;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eig.common.entity.course.EduCourse;
import com.eig.common.entity.course.EduSubject;

import com.eig.common.vo.Result;
import com.home.homepage.service.prefecture.ZoneCourseService;
import com.home.homepage.vo.prefecture.ZoneCourseId;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：YQ袁（2446806940@qq.com）
 * @date ：Created in 2022/12/7 19:55
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/home/zone-course/")
@Api(value = "专区课程")
public class ZoneCourseController {
    @Autowired
    private ZoneCourseService zoneCourseService;


//    @PostMapping("/getAllDetail/{current}/{pageSize}")
//    public Result<IPage<EduCourse>> getAllDetail(@PathVariable(required = true ) Integer current,
//                                                 @PathVariable(required = true) Integer pageSize,
//
//                                                 @RequestBody EduSubject eduSubject){
//
//        return zoneCourseService.getAllDetail(current,pageSize,eduSubject);
//    }
//  @PostMapping("/findCourse/{current}/{pageSize}")
//    public Result<IPage<EduCourse>> findCourse(@PathVariable(required = true ) Integer current,
//                                                 @PathVariable(required = true) Integer pageSize,
//
//                                                 @RequestBody EduCourse e){
//
//        return zoneCourseService.findCourse(current,pageSize,e);
//    }
//    @PostMapping("/addCourseDetail")
//    public Result<IPage<EduCourse>> addCourseDetail(@RequestBody ZoneCourseId zoneCourseId){
//        System.out.println(zoneCourseId);
//        zoneCourseService.addCourseDetail(zoneCourseId);
//        return null;
//    }


    @PostMapping("/findCourse/{current}/{pageSize}")
    @ApiOperation(value = "远程调用分页查询")
    public Result<IPage<EduCourse>> findCourse(@PathVariable(required = true ) Integer current,
                                                 @PathVariable(required = true) Integer pageSize,

                                                 @RequestBody EduCourse e){

        return zoneCourseService.findCourse(current,pageSize,e);
    }
    @PostMapping("/addCourseDetail")
    @ApiOperation(value = "添加课程")
    public Result<IPage<EduCourse>> addCourseDetail(@RequestBody ZoneCourseId zoneCourseId){
        System.out.println(zoneCourseId);
        zoneCourseService.addCourseDetail(zoneCourseId);
        return null;
    }

    @PostMapping("/getAllDetail/{current}/{pageSize}/{id}")
    @ApiOperation(value = "分页")
    public Result getAllDetail(@PathVariable(required = true ) Integer current,
                               @PathVariable(required = true) Integer pageSize,
                               @PathVariable String id,
                               @RequestBody EduSubject eduSubject){
        PageRequest pageRequest = PageRequest.of(current - 1, pageSize);
        return    zoneCourseService.findsubject(pageRequest, eduSubject,id);
    }
}
